<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-examQuestion-edit" th:object="${examQuestion}">
            <input id="id" name="id" th:field="*{id}"  type="hidden">
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">试题类型</label>
						<div class="col-sm-8">
							<div class="input-group" style="width: 100%">
								<select name="type" class="form-control m-b" th:with="type=${@dict.getType('exam_question_type')}">
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{type}"></option>
								</select>
							</div>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">试题难度</label>
						<div class="col-sm-8">
							<div class="input-group" style="width: 100%">
								<select name="level" class="form-control m-b" th:with="type=${@dict.getType('exam_question_level')}">
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{level}"></option>
								</select>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label class="col-xs-2 control-label">试题内容</label>
						<div class="col-xs-10">
							<textarea name="question" autocomplete="off" maxlength="500" th:field="*{question}" class="form-control" rows="5" required></textarea>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label class="col-xs-2 control-label">题目解析</label>
						<div class="col-xs-10">
							<textarea name="analyze" autocomplete="off" maxlength="500" th:field="*{analyze}" class="form-control" rows="5" required></textarea>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">限时</label>
						<div class="col-sm-8">
							<input id="timeLimit" name="timeLimit"  th:field="*{timeLimit}" class="form-control" type="text" required>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">试题状态</label>
						<div class="col-sm-8">
							<div class="onoffswitch">
								<input type="checkbox" th:checked="${examQuestion.status == 0 ? true : false}" class="onoffswitch-checkbox" id="status">
								<label class="onoffswitch-label" for="status">
									<span class="onoffswitch-inner"></span>
									<span class="onoffswitch-switch"></span>
								</label>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">A</label>
				<div class="col-sm-8">
					<input id="answerContentA" name="answerContentA" th:field="*{answerContentA}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">B</label>
				<div class="col-sm-8">
					<input id="answerContentB" name="answerContentB" th:field="*{answerContentB}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">C</label>
				<div class="col-sm-8">
					<input id="answerContentC" name="answerContentC" th:field="*{answerContentC}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">D</label>
				<div class="col-sm-8">
					<input id="answerContentD" name="answerContentD" th:field="*{answerContentD}" class="form-control" type="text">
				</div>
			</div>

			<label class="col-sm-3 control-label">正确答案为:</label>
			<div class="col-sm-9" style="width: 100px">
				<select class="form-control" name="answer" th:field="*{answer}" th:value="*{answer}" lay-verify="required" id="ans">
					<option th:selected="${answer=='A'}" value="A">A</option>
					<option th:selected="${answer=='B'}" value="B">B</option>
					<option th:selected="${answer=='C'}" value="C">C</option>
					<option th:selected="${answer=='D'}" value="D">D</option>
				</select>
			</div>

		</form>
    </div>

	<div class="row">
		<div class="col-sm-offset-5 col-sm-10">
			<button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
			<button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
		</div>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "system/examQuestion";
		$("#form-examQuestion-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});

		function submitHandler() {
	        if ($.validate.form()) {
                var data = $("#form-examQuestion-edit").serializeArray();
                var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
                data.push({"name": "status", "value": status});
                var isSpecial = $("input[id='isSpecial']").is(':checked') == true ? 0 : 1;
                data.push({"name": "isSpecial", "value": isSpecial});
                $.operate.saveTab(prefix + "/edit", data);
	        }
	    }
	</script>
</body>
</html>
